const common={
	// numberToChinese(num){
	// 	const c=['一','二','三','四','五','六','七','八','九'];
	// 	return c[num-1]
	// },
	userMainImg(){
		return 'https://1322345190.vod-qcloud.com/fd615140vodcq1322345190/126a47db5145403700591633347/JS3Cnq1PL7YA.png'
	},
	numberToChinese(num) {
	    const chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
	    const units = ['', '十', '百'];
	    
	    if (num < 0 || num > 999) {
	        throw new Error('只支持0-999之间的数字');
	    }
	    
	    if (num === 0) return '零';
	    
	    let result = '';
	    const str = num.toString();
	    
	    for (let i = 0; i < str.length; i++) {
	        const digit = parseInt(str[i]);
	        const unitIndex = str.length - i - 1;
	        
	        if (digit !== 0) {
	            result += chineseNumbers[digit] + units[unitIndex];
	        } else if (i > 0 && str[i - 1] !== '0') {
	            result += '零';
	        }
	    }
	    
	    // 处理特殊情况：一十 -> 十
	    if (result.startsWith('一十')) {
	        result = result.substring(1);
	    }
	    
	    // 去除连续的零
	    result = result.replace(/零+/g, '零');
	    
	    // 去除末尾的零
	    result = result.replace(/零$/, '');
	    
	    return result;
	},
	isEmpty(value) {
		if (value == null) return true;
		if (typeof value === 'boolean') return !value;
		if (typeof value === 'string') return value.length === 0;
		if (Array.isArray(value)) return value.length === 0;
		if (typeof value === 'object') return Object.keys(value).length === 0;
		return false;
	},
	// 生成 UUID v4
	generateUUID() {
	  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
	    const r = (Math.random() * 16) | 0;
	    const v = c === 'x' ? r : (r & 0x3 | 0x8);
	    return v.toString(16);
	  }) + '-' + Date.now();
	},
	// 日期处理
	dateFormat(d,type){
		let date=new Date(d);
		if(!d){
			date=new Date()
		}
		if(type=='1'){
			return `${(date.getMonth()+1).toString().padStart(2, '0')}月${date.getDate().toString().padStart(2, '0')}日${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`
		}
		return `${date.getFullYear()}-${(date.getMonth()+1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`
	},
	createFakeProgress() {
	  return {
	    progress: 0,
	    timer: null,
	
	    start() {
	      this.progress = 0
	      const duration = Math.floor(Math.random() * 2000) + 2000 // 2-4秒
	      const stepTime = 50
	      const steps = duration / stepTime
	      const increment = 100 / steps
	
	      this.stop() // 避免重复 start 残留定时器
	
	      this.timer = setInterval(() => {
	        if (this.progress < 100) {
	          this.progress = Math.min(100, this.progress + increment)
	        } else {
	          this.stop()
	        }
	      }, stepTime)
	    },
	
	    stop() {
	      if (this.timer) {
	        clearInterval(this.timer)
	        this.timer = null
	      }
	    },
	
	    reset() {
	      this.stop()
	      this.progress = 0
	    }
	  }
	},
	getDaysFromDate(dateString) {
	  const oneDay = 24 * 60 * 60 * 1000;
	  const targetDate = new Date(dateString);
	  const today = new Date();
	  today.setHours(0, 0, 0, 0);
	  return Math.ceil((targetDate - today) / oneDay);
	},
	//视频时长转换
	videoTimeForamt(time){
		if(!time) return '00:00';
		if(time.indexOf(':')!=-1 || time.indexOf('：')!=-1) return time;
		let h=Math.floor(time/3600),
			m=Math.floor(time/60),
			s=0;
		if(time>=3600){
			h=h<10 ? '0'+h : h;
			m=m%60<10 ? '0'+m%60 : m%60;
			s=time%60 <10 ? '0'+time%60 : time%60;
			return h+':'+m+':'+s
		}else if(time>=60){
			m=m<10 ? '0'+m : m;
			s=time%60 <10 ? '0'+time%60 : time%60;
			return m+':'+s
		}else{
			m='00'
			s=time<10 ? '0'+time : time
			return m+':'+s
		}
	},
	scoreFromat(n){
		let numKey={
			27: '200',
			28: '203',
			29: '205',
			30: '208',
			31: '210',
			32: '213',
			33: '215',
			34: '218',
			35: '220',
			36: '222',
			37: '225',
			38: '228',
			39: '230',
			40: '232',
			41: '233',
			42: '235',
			43: '237',
			44: '239',
			45: '241',
			46: '243',
			47: '246',
			48: '248',
			49: '250',
			50: '251',
			51: '255',
			52: '258',
			53: '260',
			54: '265',
			55: '268',
			56: '271',
			57: '274',
			58: '277',
			59: '280',
			60: '284',
			61: '287',
			62: '292',
			63: '296',
			64: '299',
			65: '300',
			66: '302',
			67: '304',
			68: '306',
			69: '308',
			70: '310',
			71: '311',
			72: '313',
			73: '314',
			74: '315',
			75: '316',
			76: '317',
			77: '318',
			78: '319',
			79: '320',
			80: '321',
			81: '322',
			82: '324',
			83: '325',
			84: '326',
			85: '327',
			86: '328',
			87: '329',
			88: '330',
			89: '331',
			90: '332',
			91: '333',
			92: '335',
			93: '336',
			94: '338',
			95: '339',
			96: '341',
			97: '342',
			98: '343',
			99: '345',
			100: '346',
			101: '348',
			102: '350',
			103: '353',
			104: '354',
			105: '356',
			106: '357',
			107: '360',
			108: '362',
			109: '363',
			110: '365',
			111: '366',
			112: '368',
			113: '369',
			114: '370',
			115: '371',
			116: '373',
			117: '375',
			118: '376',
			119: '378',
			120: '380',
		}
		return numKey[n] || n
	}
}
export default common